package com.hongxun.design.bean;

import com.alibaba.fastjson.JSON;
import com.hongxun.design.MyApp;
import com.hongxun.design.mytools.MString;
import com.hongxun.design.utils.StringUtil;

/**
 * Created by zerdoor_pc on 2016/5/30.
 */
public class ProjectItemBean {

    public String project_id = "";
    public String stage_id = "";
    public String project_name = "";
    public String stage_name = "";
    public String lng = "";
    public String lat = "";
    public String thumb = "";
    public String project_type = "";
    public String stage = "";
    public String schedule = "";
    public String is_exp = "";
    public String is_finish = "";
    public String create_time = "";
    public String codeset_version_id = "";
    public String manager = "";
    public String manager_name = "";
    public String explorationer = "";
    public String explorationer_name = "";
    public String designer = "";
    public String auditor = "";
    public String uuid = "";
    public String current_stage = "";
    public String cost_center = "";

    public String flag = MString.add;

    //不存储
    public void setBean(ProjectItemBean bean,int i) {
        if (bean==null)return;
        clearBean();
        project_id = bean.getProject_id();
        stage_id = bean.getStage_id();
        project_name = bean.getProject_name();
        stage_name = bean.getStage_name();
        lng = bean.getLng();
        lat = bean.getLat();
        thumb = bean.getThumb();
        project_type = bean.getProject_type();
        stage = bean.getStage();
        schedule = bean.getCurrent_schedule();
        is_exp = bean.getIs_exp();
        is_finish = bean.getIs_finish();
        create_time = bean.getCreate_time();
        codeset_version_id = bean.getCodeset_version_id();
        manager = bean.getManager();
        explorationer = bean.getExplorationer();
        designer = bean.getDesigner();
        auditor = bean.getAuditor();
        uuid = bean.getUUID();
        flag = bean.getFlag();
        manager_name=bean.getManager_name();
        explorationer_name=bean.getExplorationer_name();
        cost_center = bean.getCost_center();
        current_stage = bean.getCurrent_stage();
    }
    public String codeset_version = "";
    public String power_zone = "";
    public String weather_zone = "";
    public String address = "";
//    public String project_attribute = "",region = "",address = "",detail_address = "",
//            soil = "",transport = "",wire_type = "",design_unit = "",
//            project_attribute = "",project_attribute = "";
    //补全信息(特殊处理只在二维码的时候用)//weather_zone,power_zone,codeset_version_id,
    // project_attribute,region,address,detail_address,soil
    // ,transport,wire_type,design_unit,owner_unit,linkman,linkphone,
    // characters_remark,voice_remark
    public void setBeanWithNo(ProjectItemBean bean) {
        if (bean==null)return;
        if (StringUtil.isEmpty(project_id)) project_id = bean.getProject_id();
        if (StringUtil.isEmpty(stage_id)) stage_id = bean.getStage_id();
        if (StringUtil.isEmpty(project_name)) project_name = bean.getProject_name();
        if (StringUtil.isEmpty(stage_name)) stage_name = bean.getStage_name();
        if (StringUtil.isEmpty(lng)) lng = bean.getLng();
        if (StringUtil.isEmpty(lat)) lat = bean.getLat();
        if (StringUtil.isEmpty(thumb)) thumb = bean.getThumb();
        if (StringUtil.isEmpty(project_type)) project_type = bean.getProject_type();
        if (StringUtil.isEmpty(stage)) stage = bean.getStage();
        if (StringUtil.isEmpty(schedule)) schedule = bean.getCurrent_schedule();
        if (StringUtil.isEmpty(is_exp))  is_exp = bean.getIs_exp();
        if (StringUtil.isEmpty(is_finish))  is_finish = bean.getIs_finish();
        if (StringUtil.isEmpty(create_time)) create_time = bean.getCreate_time();
        if (StringUtil.isEmpty(codeset_version_id)) codeset_version_id = bean.getCodeset_version_id();
        if (StringUtil.isEmpty(codeset_version)) codeset_version = bean.getCodeset_version();
        if (StringUtil.isEmpty(weather_zone)) weather_zone = bean.getWeather_zone();
        if (StringUtil.isEmpty(power_zone)) power_zone = bean.getPower_zone();
        if (StringUtil.isEmpty(address)) address = bean.getAddress();
//        if (StringUtil.isEmpty(manager))  manager = bean.getManager();
//        if (StringUtil.isEmpty(explorationer))  explorationer = bean.getExplorationer();
        if (StringUtil.isEmpty(designer))   designer = bean.getDesigner();
//        if (StringUtil.isEmpty(auditor)) auditor = bean.getAuditor();
        if (StringUtil.isEmpty(uuid)) uuid = bean.getUUID();
        if (StringUtil.isEmpty(flag))  flag = bean.getFlag();
//        if (StringUtil.isEmpty(manager_name))   manager_name=bean.getManager_name();
//        if (StringUtil.isEmpty(explorationer_name))  explorationer_name=bean.getExplorationer_name();
        if (StringUtil.isEmpty(cost_center))  cost_center = bean.getCost_center();
        if (StringUtil.isEmpty(current_stage))   current_stage = bean.getCurrent_stage();
    }
      //不存储
    public void setBeanToHas(ProjectItemBean bean) {
        if (bean==null)return;

      if (bean.getProject_id().length()>0) project_id = bean.getProject_id();
        if (bean.getStage_id().length()>0) stage_id = bean.getStage_id();
        if (bean.getProject_name().length()>0) project_name = bean.getProject_name();
        if (bean.getStage_name().length()>0) stage_name = bean.getStage_name();
        if (bean.getLng().length()>0) lng = bean.getLng();
        if (bean.getLat().length()>0) lat = bean.getLat();
        if (bean.getThumb().length()>0) thumb = bean.getThumb();
        if (bean.getProject_type().length()>0) project_type = bean.getProject_type();
        if (bean.getStage().length()>0) stage = bean.getStage();
        if (bean.getCurrent_schedule().length()>0) schedule = bean.getCurrent_schedule();
        if (bean.getIs_exp().length()>0)  is_exp = bean.getIs_exp();
        if (bean.getIs_finish().length()>0)  is_finish = bean.getIs_finish();
        if (bean.getCreate_time().length()>0) create_time = bean.getCreate_time();
        if (bean.getCodeset_version_id().length()>0) codeset_version_id = bean.getCodeset_version_id();
        if (bean.getManager().length()>0)  manager = bean.getManager();
        if (bean.getExplorationer().length()>0)  explorationer = bean.getExplorationer();
        if (bean.getDesigner().length()>0)   designer = bean.getDesigner();
        if (bean.getAuditor().length()>0) auditor = bean.getAuditor();
        if (bean.getUUID().length()>0) uuid = bean.getUUID();
        if (bean.getFlag().length()>0)  flag = bean.getFlag();
        if (bean.getManager_name().length()>0)   manager_name=bean.getManager_name();
        if (bean.getExplorationer_name().length()>0)  explorationer_name=bean.getExplorationer_name();
        if (bean.getCost_center().length()>0)  cost_center = bean.getCost_center();
        if (bean.getCurrent_stage().length()>0)   current_stage = bean.getCurrent_stage();

    }
    //存储
    public void setBean(ProjectItemBean bean) {
        if (bean==null)return;
        clearBean();
        project_id = bean.getProject_id();
        stage_id = bean.getStage_id();
        project_name = bean.getProject_name();
        stage_name = bean.getStage_name();
        lng = bean.getLng();
        lat = bean.getLat();
        thumb = bean.getThumb();
        project_type = bean.getProject_type();
        stage = bean.getStage();
        schedule = bean.getCurrent_schedule();
        is_exp = bean.getIs_exp();
        is_finish = bean.getIs_finish();
        create_time = bean.getCreate_time();
        codeset_version_id = bean.getCodeset_version_id();
        manager = bean.getManager();
        explorationer = bean.getExplorationer();
        manager_name=bean.getManager_name();
        explorationer_name=bean.getExplorationer_name();
        designer = bean.getDesigner();
        auditor = bean.getAuditor();
        uuid = bean.getUUID();
        flag = bean.getFlag();
        cost_center = bean.getCost_center();
        current_stage = bean.getCurrent_stage();
        if (is_exp.equals(MString.code_zero)) {
            MyApp.ReadOnly = false;
        } else if (is_exp.equals(MString.code_one)){
            MyApp.ReadOnly = true;
        }else{
            is_exp=MString.code_zero;
            MyApp.ReadOnly = false;
        }

//        if (schedule.equals("14")){
//            MyApp.ReadOnly2=true;
//        }else{
//            MyApp.ReadOnly2=false;
//        }
        saveBean();

    }

    public void setSearchBean(SearchProjectBean bean, int i) {
        if (bean==null)return;
        clearBean();
        project_id = bean.getProject_id();
        project_name = bean.getProject_name();
        lng = bean.getLng();
        lat = bean.getLat();

        thumb = bean.getThumb();
        project_type = bean.getProject_type();
        is_finish = bean.getIs_finish();
        codeset_version_id = bean.getCodeset_version_id();
        //stage_name=bean.getStage();
        schedule = splt(bean.getSchedule(), i);
        is_exp = splt(bean.getIs_exp(), i);
        create_time = splt(bean.getCreate_time(), i);
        stage = splt(bean.getStage(), i);
        stage_id = splt(bean.getStage_ids(), i);
        manager = bean.getManager();
        explorationer = bean.getExplorationer();
        designer = bean.getDesigner();
        auditor = bean.getAuditor();
        uuid = bean.getUUID();
        flag = bean.getFlag();
        cost_center = bean.getCost_center();
        current_stage=bean.getCurrent_stage();

        if (is_exp.equals(MString.code_zero)) {
            MyApp.ReadOnly = false;
        } else if (is_exp.equals(MString.code_one)){
            MyApp.ReadOnly = true;
        }else{
            is_exp=MString.code_zero;
            MyApp.ReadOnly = false;
        }
        saveBean();
    }

    public void saveBean(){
        MyApp.File.SaveFileData(MString.currProject, JSON.toJSONString(this));
    }

    public void saveNullBean(){
        clearBean();
        MyApp.File.SaveFileData(MString.currProject, JSON.toJSONString(this));
    }

    private String splt(String s, int point) {
        try {
            String[] tar = s.split(",");
            if (tar[point] != null && tar[point].length() > 0) {
                return tar[point];
            } else {
                return "";
            }
        }catch (Exception e){
            return "";
        }

    }



    public String getFlag() {
        return flag;
    }

    public void setFlag(String flag) {
        this.flag = flag;
    }

    public void clearBean() {
        project_id = "";
        stage_id = "";
        project_name = "";
        stage_name = "";
        lng = "";
        lat = "";
        thumb = "";
        project_type = "";
        stage = "";
        schedule = "";
        is_exp = "";
        is_finish = "";
        create_time = "";
        codeset_version_id = "";
        codeset_version = "";
        manager = "";
        explorationer = "";
        designer = "";
        auditor ="";
        uuid = "";
        manager_name="";
        explorationer_name="";
        cost_center="";
        current_stage="";
        weather_zone="";
        power_zone="";
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getCodeset_version() {
        return codeset_version;
    }

    public void setCodeset_version(String codeset_version) {
        this.codeset_version = codeset_version;
    }

    public String getPower_zone() {
        return power_zone;
    }

    public void setPower_zone(String power_zone) {
        this.power_zone = power_zone;
    }

    public String getWeather_zone() {
        return weather_zone;
    }

    public void setWeather_zone(String weather_zone) {
        this.weather_zone = weather_zone;
    }

    public String getCurrent_stage() {
        return current_stage;
    }

    public void setCurrent_stage(String current_stage) {
        this.current_stage = current_stage;
    }

    public String getCost_center() {
        return cost_center;
    }

    public void setCost_center(String cost_center) {
        this.cost_center = cost_center;
    }

    public String getExplorationer_name() {
        return explorationer_name;
    }

    public void setExplorationer_name(String explorationer_name) {
        this.explorationer_name = explorationer_name;
    }

    public String getManager_name() {
        return manager_name;
    }

    public void setManager_name(String manager_name) {
        this.manager_name = manager_name;
    }

    public String getUUID() {
        if (uuid==null)return "";
        return uuid;
    }

    public void setUUID(String uuid) {
        this.uuid = uuid;
    }

    public String getManager() {
        return manager;
    }

    public void setManager(String manager) {
        this.manager = manager;
    }

    public String getExplorationer() {
        return explorationer;
    }

    public void setExplorationer(String explorationer) {
        this.explorationer = explorationer;
    }

    public String getDesigner() {
        return designer;
    }

    public void setDesigner(String designer) {
        this.designer = designer;
    }

    public String getAuditor() {
        return auditor;
    }

    public void setAuditor(String auditor) {
        this.auditor = auditor;
    }

    public String getCodeset_version_id() {
        return codeset_version_id;
    }

    public void setCodeset_version_id(String codeset_version_id) {
        this.codeset_version_id = codeset_version_id;
    }

    public String getIs_finish() {
        return is_finish;
    }

    public void setIs_finish(String is_finish) {
        this.is_finish = is_finish;
    }


    public String getProject_id() {
        return project_id;
    }

    public void setProject_id(String project_id) {
        this.project_id = project_id;
    }

    public String getStage_id() {
        if (stage_id==null||stage_id==MString.code_zero)return "";
        return stage_id;
    }

    public void setStage_id(String stage_id) {
        this.stage_id = stage_id;
    }

    public String getProject_name() {
        return project_name;
    }

    public void setProject_name(String project_name) {
        this.project_name = project_name;
    }

    public String getStage_name() {
        return stage_name;
    }

    public void setStage_name(String stage_name) {
        this.stage_name = stage_name;
    }

    public String getThumb() {
        return thumb;
    }

    public void setThumb(String thumb) {
        this.thumb = thumb;
    }

    public String getProject_type() {
        return project_type;
    }

    public void setProject_type(String project_type) {
        this.project_type = project_type;
    }

    public String getStage() {
        return stage;
    }

    public void setStage(String stage) {
        this.stage = stage;
    }

    public String getCurrent_schedule() {
        return schedule;
    }

    public void setCurrent_schedule(String current_schedule) {
        this.schedule = current_schedule;
    }

    public String getIs_exp() {
        return is_exp;
    }

    public void setIs_exp(String is_exp) {
        this.is_exp = is_exp;
    }

    public String getCreate_time() {
        return create_time;
    }

    public void setCreate_time(String create_time) {
        this.create_time = create_time;
    }

    public String getLng() {
        return lng;
    }

    public void setLng(String lng) {
        this.lng = lng;
    }

    public String getLat() {
        return lat;
    }

    public void setLat(String lat) {
        this.lat = lat;
    }

}
